package com.qidian.buy.cms.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.qidian.buy.cms.entity.ContentCategory;
import com.qidian.buy.cms.service.IContentCategoryService;
import com.qidian.buy.util.pojo.QdResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 戴着假发的程序员
 * @since 2024-05-06
 */
@RestController
@RequestMapping("/contentCategory")
public class ContentCategoryController {
    @Autowired
    private IContentCategoryService contentCategoryService;
    @GetMapping("/queryByParentId")
    public QdResult<IPage<ContentCategory>> queryByParentId(Long parentId, @RequestParam(defaultValue = "1")int page, @RequestParam(defaultValue = "10") int limit){
        return contentCategoryService.queryByParentIdAndPage(parentId,page,limit);
    }

    @PostMapping("save")
    public QdResult save(@RequestBody ContentCategory category){
        return contentCategoryService.saveContentCat(category);
    }
    @GetMapping("/list")
    public QdResult<List<ContentCategory>> list(){
        return contentCategoryService.queryAll();
    }
}
